package com.joolun.web.controller.activity;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.joolun.common.annotation.Log;
import com.joolun.common.core.controller.BaseController;
import com.joolun.common.core.domain.AjaxResult;
import com.joolun.common.enums.BusinessType;
import com.joolun.activity.domain.ShareInfo;
import com.joolun.activity.service.IShareInfoService;
import com.joolun.common.utils.poi.ExcelUtil;
import com.joolun.common.core.page.TableDataInfo;

/**
 * 年味分享Controller
 *
 * @author www.joolun.com
 * @date 2023-01-18
 */
@RestController
@RequestMapping("/activity/ShareInfo")
public class ShareInfoController extends BaseController
{
    @Autowired
    private IShareInfoService shareInfoService;

    /**
     * 查询年味分享列表
     */
    @PreAuthorize("@ss.hasPermi('activity:ShareInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShareInfo shareInfo)
    {
        startPage();
        List<ShareInfo> list = shareInfoService.selectShareInfoList(shareInfo);
        return getDataTable(list);
    }

    /**
     * 导出年味分享列表
     */
    @PreAuthorize("@ss.hasPermi('activity:ShareInfo:export')")
    @Log(title = "年味分享", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ShareInfo shareInfo)
    {
        List<ShareInfo> list = shareInfoService.selectShareInfoList(shareInfo);
        ExcelUtil<ShareInfo> util = new ExcelUtil<ShareInfo>(ShareInfo.class);
        return util.exportExcel(list, "ShareInfo");
    }

    /**
     * 获取年味分享详细信息
     */
    @PreAuthorize("@ss.hasPermi('activity:ShareInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(shareInfoService.selectShareInfoById(id));
    }

    /**
     * 新增年味分享
     */
    @PreAuthorize("@ss.hasPermi('activity:ShareInfo:add')")
    @Log(title = "年味分享", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShareInfo shareInfo)
    {
        return toAjax(shareInfoService.insertShareInfo(shareInfo));
    }

    /**
     * 修改年味分享
     */
    @PreAuthorize("@ss.hasPermi('activity:ShareInfo:edit')")
    @Log(title = "年味分享", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShareInfo shareInfo)
    {
        return toAjax(shareInfoService.updateShareInfo(shareInfo));
    }

    /**
     * 删除年味分享
     */
    @PreAuthorize("@ss.hasPermi('activity:ShareInfo:remove')")
    @Log(title = "年味分享", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(shareInfoService.deleteShareInfoByIds(ids));
    }
}
